package com.ssyt.yt1.day21;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * 文件剪切功能的实现
 * 
 * @author Administrator
 *
 */
public class FileCutDemo {

	public static void main(String[] args) throws IOException {
		File srcFile = new File("d:/Adobe_Flash_CS6.exe");
		// 1、InputStream
		InputStream inputStream = null;
		// 2、OutputStream
		OutputStream outputStream = null;
		try {
			inputStream = new FileInputStream(srcFile);
			outputStream = new FileOutputStream("e:/[xxx]Adobe_Flash_CS6.exe");
			byte[] bytes = new byte[1024]; // 1
			int len = 0;
			while ((len = inputStream.read(bytes)) != -1) {
				outputStream.write(bytes, 0, len);
			}
		} finally {
			if (inputStream != null) {
				inputStream.close();
			}
			if (outputStream != null) {
				outputStream.close();
			}
		}
		// 3、文本本身删除
		System.out.println(srcFile.delete());
		System.out.println("文件剪切成功~");
	}
}
